package com.amit.struts;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class EnquiryTimingsAction extends Action {
	
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		EnquiryTimingsForm ef=(EnquiryTimingsForm)form;
		
		//1.collect the data
		String timings=ef.getTimings();
		
		String result=" ";
		
		//2.contact the model
		if(timings.equals("10.00A.M-2.00P.M"))
		{
			result="success";
			
			ArrayList<EnquiryTO> list=new ArrayList<EnquiryTO>();
			EnquiryTO eto=new EnquiryTO();
			eto.setEid("E-1001");
			eto.setFullname("amit yadav");
			eto.setEmail("amit@gmail.com");
			eto.setPhone("122");
			eto.setTimings(timings);
			
			list.add(eto);list.add(eto);
			list.add(eto);list.add(eto);
			list.add(eto);list.add(eto);
			request.setAttribute("LIST", list);
			
			
		}
		else
		{
			throw new NOEnquiryFoundException();
		}
		
		ActionForward forward=mapping.findForward(result);
		
				return forward;
	
	}

}
